﻿using System;
using System.Collections;
using SolidEdgeGeometry;

namespace MultiConvert
{
    internal class SEPartConverter : SEDocumentConverter 
    {
        protected SolidEdgePart.PartDocument Document;               
        protected String ToFile;
        
        public SEPartConverter()
        {
        	
        }
        
        public SEPartConverter(Object SolidEdgeDoc, SEApplicationWrapper parent)
        {
            this.Application = parent;
            this.Document = (SolidEdgePart.PartDocument)SolidEdgeDoc;
            this.HighlightSets = this.Document.HighlightSets;            
        }

        internal override String convert(String ConvertMethod, String toFileName)
        {
            this.ConversionResult = Properties.Resources.MsgConvFailed;
            this.ToFile = toFileName;

            switch (ConvertMethod)
            {
                case "par2x_t":
            	case "par2igs":
                case "par2jt":
                case "par2stp":
            		this.ConversionResult = this.SaveAs( (SolidEdgeFramework.SolidEdgeDocument)this.Document, toFileName, ConvertMethod );                    
                    break;

                case "par2jpg":
                    this.ConversionResult = this.SaveAsImage((SolidEdgeFramework.SolidEdgeDocument)this.Document, toFileName, ConvertMethod);
                    break;

                case "par2par_norm": 
                    // Set NormPart & Save
                    this.Document.HardwareFile = true;
                    this.ConversionResult = this.SaveAs((SolidEdgeFramework.SolidEdgeDocument)this.Document, toFileName, ConvertMethod);

                    this.ConversionResult = this.ConversionResult + " to Version " + this.Document.LastSavedVersion;
                    // FB#6174 see at /PLMA/IF_EX_CONV_MAIN~AFTER_CHECKIN
                    String Path = System.IO.Path.GetDirectoryName(toFileName);                    
                    String File = Path + "\\SEVersion_" + this.Document.LastSavedVersion;
                    System.IO.File.Delete(File);
                    System.IO.File.Create(File);

                    break;
                    
                default:
                    this.ConversionResult = Properties.Resources.MsgNoConvImplemented;
                    break;
            }
            
            return this.ConversionResult;
        }

        
    }   
}
